package com.codeZ.Prototypepattern;

import cn.hutool.core.bean.BeanUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 原型
 *
 * @author codeZhang
 * @Date 2024/8/6 15:24
 */
@Data
public class ConcretePrototype implements Cloneable, Serializable {

    void show(){
        System.out.println("嫌疑人姓名: " +person.getName());
    }

    public ConcretePrototype() {
        System.out.println("具体的原型对象创建完成!");
    }

    private Person person;

    @Override
    public ConcretePrototype clone() {
        try {
            return (ConcretePrototype) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new AssertionError();
        }
    }


}

@Data
@AllArgsConstructor
@NoArgsConstructor
class Person implements Serializable{
    private String name;
}